//
// CPointLight.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------







package org.ryzom.nel.threed;

import org.ryzom.nel.misc.CRGBA;
import org.ryzom.nel.misc.CVector;
import org.ryzom.nel.misc.IStream;

public class CPointLight {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CPointLight(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CPointLight obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nel3dJNI.delete_CPointLight(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public CPointLight() {
    this(nel3dJNI.new_CPointLight__SWIG_0(), true);
  }

  public CPointLight(CPointLight o) {
    this(nel3dJNI.new_CPointLight__SWIG_1(CPointLight.getCPtr(o), o), true);
  }

  public CPointLight assign(CPointLight o) {
    return new CPointLight(nel3dJNI.CPointLight_assign(swigCPtr, this, CPointLight.getCPtr(o), o), false);
  }

  public void setType(CPointLight.TType type) {
    nel3dJNI.CPointLight_setType(swigCPtr, this, type.swigValue());
  }

  public CPointLight.TType getType() {
    return CPointLight.TType.swigToEnum(nel3dJNI.CPointLight_getType(swigCPtr, this));
  }

  public void setPosition(CVector v) {
    nel3dJNI.CPointLight_setPosition(swigCPtr, this, CVector.getCPtr(v), v);
  }

  public CVector getPosition() {
    return new CVector(nel3dJNI.CPointLight_getPosition(swigCPtr, this), false);
  }

  public void setAmbient(CRGBA ambient) {
    nel3dJNI.CPointLight_setAmbient(swigCPtr, this, CRGBA.getCPtr(ambient), ambient);
  }

  public void setDiffuse(CRGBA diffuse) {
    nel3dJNI.CPointLight_setDiffuse(swigCPtr, this, CRGBA.getCPtr(diffuse), diffuse);
  }

  public void setSpecular(CRGBA specular) {
    nel3dJNI.CPointLight_setSpecular(swigCPtr, this, CRGBA.getCPtr(specular), specular);
  }

  public void setColor(CRGBA color) {
    nel3dJNI.CPointLight_setColor(swigCPtr, this, CRGBA.getCPtr(color), color);
  }

  public CRGBA getAmbient() {
    return new CRGBA(nel3dJNI.CPointLight_getAmbient(swigCPtr, this), true);
  }

  public CRGBA getDiffuse() {
    return new CRGBA(nel3dJNI.CPointLight_getDiffuse(swigCPtr, this), true);
  }

  public CRGBA getSpecular() {
    return new CRGBA(nel3dJNI.CPointLight_getSpecular(swigCPtr, this), true);
  }

  public void setupAttenuation(float attenuationBegin, float attenuationEnd) {
    nel3dJNI.CPointLight_setupAttenuation(swigCPtr, this, attenuationBegin, attenuationEnd);
  }

  public float getAttenuationBegin() {
    return nel3dJNI.CPointLight_getAttenuationBegin(swigCPtr, this);
  }

  public float getAttenuationEnd() {
    return nel3dJNI.CPointLight_getAttenuationEnd(swigCPtr, this);
  }

  public void setupSpotAngle(float spotAngleBegin, float spotAngleEnd) {
    nel3dJNI.CPointLight_setupSpotAngle(swigCPtr, this, spotAngleBegin, spotAngleEnd);
  }

  public float getSpotAngleBegin() {
    return nel3dJNI.CPointLight_getSpotAngleBegin(swigCPtr, this);
  }

  public float getSpotAngleEnd() {
    return nel3dJNI.CPointLight_getSpotAngleEnd(swigCPtr, this);
  }

  public void setupSpotDirection(CVector dir) {
    nel3dJNI.CPointLight_setupSpotDirection(swigCPtr, this, CVector.getCPtr(dir), dir);
  }

  public CVector getSpotDirection() {
    return new CVector(nel3dJNI.CPointLight_getSpotDirection(swigCPtr, this), false);
  }

  public void serial(IStream f) {
    nel3dJNI.CPointLight_serial(swigCPtr, this, IStream.getCPtr(f), f);
  }

  public float computeLinearAttenuation(CVector pos) {
    return nel3dJNI.CPointLight_computeLinearAttenuation__SWIG_0(swigCPtr, this, CVector.getCPtr(pos), pos);
  }

  public float computeLinearAttenuation(CVector pos, float precomputedDist, float modelRadius) {
    return nel3dJNI.CPointLight_computeLinearAttenuation__SWIG_1(swigCPtr, this, CVector.getCPtr(pos), pos, precomputedDist, modelRadius);
  }

  public float computeLinearAttenuation(CVector pos, float precomputedDist) {
    return nel3dJNI.CPointLight_computeLinearAttenuation__SWIG_2(swigCPtr, this, CVector.getCPtr(pos), pos, precomputedDist);
  }

  public void setupDriverLight(CLight light, short factor) {
    nel3dJNI.CPointLight_setupDriverLight(swigCPtr, this, CLight.getCPtr(light), light, factor);
  }

  public void setupDriverLightUserAttenuation(CLight light, short factor) {
    nel3dJNI.CPointLight_setupDriverLightUserAttenuation(swigCPtr, this, CLight.getCPtr(light), light, factor);
  }

  public void resetLightedModels() {
    nel3dJNI.CPointLight_resetLightedModels(swigCPtr, this);
  }

  public SWIGTYPE_p_NL3D__CPointLight__TTransformList__iterator appendLightedModel(CTransform model) {
    return new SWIGTYPE_p_NL3D__CPointLight__TTransformList__iterator(nel3dJNI.CPointLight_appendLightedModel(swigCPtr, this, CTransform.getCPtr(model), model), true);
  }

  public void removeLightedModel(SWIGTYPE_p_NL3D__CPointLight__TTransformList__iterator it) {
    nel3dJNI.CPointLight_removeLightedModel(swigCPtr, this, SWIGTYPE_p_NL3D__CPointLight__TTransformList__iterator.getCPtr(it));
  }

  public static void purge() {
    nel3dJNI.CPointLight_purge();
  }

  public boolean getAddAmbientWithSun() {
    return nel3dJNI.CPointLight_getAddAmbientWithSun(swigCPtr, this);
  }

  public void setAddAmbientWithSun(boolean state) {
    nel3dJNI.CPointLight_setAddAmbientWithSun(swigCPtr, this, state);
  }

  public final static class TType {
    public final static TType PointLight = new TType("PointLight", nel3dJNI.CPointLight_PointLight_get());
    public final static TType SpotLight = new TType("SpotLight");
    public final static TType AmbientLight = new TType("AmbientLight");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TType swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TType.class + " with value " + swigValue);
    }

    private TType(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TType(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TType(String swigName, TType swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TType[] swigValues = { PointLight, SpotLight, AmbientLight };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

}
